/*
 * @:
 * @version: 1.0
 * @Author: ziwei
 * @Date: 2021-10-18 23:56:08
 * @LastEditors: ziwei
 * @LastEditTime: 2021-11-01 11:53:52
 */
import * as actionTypes from '../action-types';
//counter1 组件对应的state
let intialState = { number: 0 };
//counter1对应的reducer
function counter1(state = intialState, action) {
  switch (action.type) {
    case actionTypes.ADD1:
      if (action.error) {
        return {
          number: state.number - 1,
        };
      } else {
        return {
          number: state.number + 1,
        };
      }
    case actionTypes.MINUS1:
      return {
        number: state.number - 1,
      };
    case actionTypes.CHANGE_COLOR:
      return {
        ...state,
        color: action.payload,
      };
    default:
      return state;
  }
}
export default counter1;
